<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      //键盘相关的事件
      //1.按下
      document.addEventListener('keydown', function () {
        console.log('键按下keydown');
      });
      //2.按下
      document.addEventListener('keypress', function () {
        console.log('键按下keypress');
      });
      //3.抬起
      document.addEventListener('keyup', function () {
        console.log('键按下keyup');
      });
    </script>
  </body>
</html>
